(function($) {

    $.ajaxSetup({
        timeout: 10000,
        cache: false
    });


    $(window).on("hashchange", function() {
        rotas();
    });

    function rotas() {
        var action = document.location.hash;
        if (action === "#login") {
            ajaxHTML("html/login.html");
        } else if (action === "#notas") {
            ajaxHTML("html/cdNotes.html");
        } else {
            changeHash("#login");
        }
    }
    rotas();

    function ajaxHTML(url) {
        $.ajax({
            url: url,
            dataType: "html",
            type: "get",
            cache: false
        }).done(function(data) {
            $('#loginDivTodo').html(data);
        }).fail(function() {
            alert("ajaxFail");
        });
    }

    
})(jQuery);

function changeHash(hash) {
        document.location.hash = hash;
}